<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="keywords" content="Hexo Theme Redefine">
    
    <meta name="author" content="xiaoeryu">
    <!-- preconnect -->
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>

    
    <!--- Seo Part-->
    
    <link rel="canonical" href="https://xiaoeeyu.github.io/2022/12/11/24-存储器的保护/"/>
    <meta name="robots" content="index,follow">
    <meta name="googlebot" content="index,follow">
    <meta name="revisit-after" content="1 days">
    
    
    
        
        <meta name="description" content="01. MOV DS, AX和 MOV DS, EAX这两条指令计算GDT的逻辑段地址,使用64位除法指令: eax(商)保存段地址, edx(余数)保存偏移div r&#x2F;m32">
<meta property="og:type" content="article">
<meta property="og:title" content="存储器的保护">
<meta property="og:url" content="https://xiaoeeyu.github.io/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/index.html">
<meta property="og:site_name" content="xiaoeryu">
<meta property="og:description" content="01. MOV DS, AX和 MOV DS, EAX这两条指令计算GDT的逻辑段地址,使用64位除法指令: eax(商)保存段地址, edx(余数)保存偏移div r&#x2F;m32">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://xiaoeeyu.github.io/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/1b5047235903fba8bbb50f7d347f9a3a.png">
<meta property="og:image" content="https://xiaoeeyu.github.io/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/b8566b6fdd714d9f20e7ccc8d0d9d4fe.png">
<meta property="og:image" content="https://xiaoeeyu.github.io/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/012766565620de75ea1fd36a90d8a8e7.png">
<meta property="og:image" content="https://xiaoeeyu.github.io/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/a756dd044cdd21358ddb4cd809abbf26.png">
<meta property="og:image" content="https://xiaoeeyu.github.io/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/dff722b81cbcf64715b115b92270809e.png">
<meta property="og:image" content="https://xiaoeeyu.github.io/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/cf7be462210f27a56e9cce8c87d9f08c.png">
<meta property="og:image" content="https://xiaoeeyu.github.io/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/7f3245ca542c143d7664e8a2f4f92e11.png">
<meta property="og:image" content="https://xiaoeeyu.github.io/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/834979e102d8631b7557cc77b899c79c.png">
<meta property="og:image" content="https://xiaoeeyu.github.io/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/0eb3ec5d63e3e3e6cd184b56a6239824.png">
<meta property="og:image" content="https://xiaoeeyu.github.io/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/896a649a211d80d2b5e6992a385fe38c.png">
<meta property="og:image" content="https://xiaoeeyu.github.io/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/77aebdb7c57f5f90aec1ef93d6cd2f83.png">
<meta property="og:image" content="https://xiaoeeyu.github.io/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/faa6ecfdc04064593c2187538b016d53.png">
<meta property="og:image" content="https://xiaoeeyu.github.io/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/20d38262af60146b85491f4fc9e35560.png">
<meta property="og:image" content="https://xiaoeeyu.github.io/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/9bb7c4ee6942d6799ec345ab5722dbec.png">
<meta property="og:image" content="https://xiaoeeyu.github.io/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/72cf5620753aad0a89a78fff765bab5b.png">
<meta property="og:image" content="https://xiaoeeyu.github.io/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/5f6bc86c2b0bbfa28ae3ced5216d4e23.png">
<meta property="og:image" content="https://xiaoeeyu.github.io/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/9d4184077cda167885a8ad7a748e3cf7.png">
<meta property="og:image" content="https://xiaoeeyu.github.io/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/c07413ae69547ac24bc35c6478c45746.png">
<meta property="og:image" content="https://xiaoeeyu.github.io/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/992185c00e3d10260709cc14bfc4af81.png">
<meta property="og:image" content="https://xiaoeeyu.github.io/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/38ecf365ff993ff5e8cc0d71e3e3c4b8.png">
<meta property="og:image" content="https://xiaoeeyu.github.io/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/3dbad33e467a13c4c8bb0f56683128b9.png">
<meta property="og:image" content="https://xiaoeeyu.github.io/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/650aa3cfe536d7e955920ed47a12a600.png">
<meta property="og:image" content="https://xiaoeeyu.github.io/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/1b581c0afc4c2bc3e56eb88b6ea86b95.png">
<meta property="og:image" content="https://xiaoeeyu.github.io/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/0da722cc7dd0fd58228cd9a0786f8b37.png">
<meta property="og:image" content="https://xiaoeeyu.github.io/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/5233807d22ddc7f010f94b872ed3e281.png">
<meta property="og:image" content="https://xiaoeeyu.github.io/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/9e8bead96b7411a85c63c58a3f574449.png">
<meta property="og:image" content="https://xiaoeeyu.github.io/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/c8cd77849769d1fb3edd1e0250dc51e6.png">
<meta property="og:image" content="https://xiaoeeyu.github.io/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/e8328caac6a6420bd869459b6bd1b079.png">
<meta property="og:image" content="https://xiaoeeyu.github.io/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/0666f08ce296096fab463e028efe3114.png">
<meta property="og:image" content="https://xiaoeeyu.github.io/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/1966f897d44a0bafbb6c4950cbe27596.png">
<meta property="og:image" content="https://xiaoeeyu.github.io/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/df76be4458212651a62defd71f6b34c4.png">
<meta property="og:image" content="https://xiaoeeyu.github.io/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/6a19b8a2865e1c148aede31b98375256.png">
<meta property="og:image" content="https://xiaoeeyu.github.io/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/36ee499be6eca2ea474c7240d2343bef.png">
<meta property="og:image" content="https://xiaoeeyu.github.io/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/fcb649fcc68631430ba4a99f986defb7.png">
<meta property="og:image" content="https://xiaoeeyu.github.io/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/0e52729cf791d29491cad920d07b0c53.png">
<meta property="og:image" content="https://xiaoeeyu.github.io/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/483ed43e4cf752c5847ddb7949b0e895.png">
<meta property="og:image" content="https://xiaoeeyu.github.io/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/7b46f7ff6dfa07da667fc96c766bcea2.png">
<meta property="og:image" content="https://xiaoeeyu.github.io/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/ef863300690948d99350071f8d5464b3.png">
<meta property="og:image" content="https://xiaoeeyu.github.io/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/e62ebf4b9bfa8ca5424718326670afec.png">
<meta property="og:image" content="https://xiaoeeyu.github.io/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/2951d97f1dd24b7c5e9cf3b6d522fecf.png">
<meta property="og:image" content="https://xiaoeeyu.github.io/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/15f11c6a8e4dbf4ebd18d79a9f2aecff.png">
<meta property="og:image" content="https://xiaoeeyu.github.io/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/7c598377dd29fff913aca0e7d63b922f.png">
<meta property="og:image" content="https://xiaoeeyu.github.io/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/dc8055320b99f5258a5a34c8309a7f0d.png">
<meta property="og:image" content="https://xiaoeeyu.github.io/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/391097b5520370f4dc8a85612f2a0535.png">
<meta property="og:image" content="https://xiaoeeyu.github.io/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/ff70bd2dd24a02e094faf74301722bfb.png">
<meta property="og:image" content="https://xiaoeeyu.github.io/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/440c379626a7dfa235d192c8f824473c.png">
<meta property="og:image" content="https://xiaoeeyu.github.io/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/609e6f5a2b3b335d37cfc7ebdd66a3ab.png">
<meta property="og:image" content="https://xiaoeeyu.github.io/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/4c5d56edda424f8df68ea1ca6ab0198f.png">
<meta property="og:image" content="https://xiaoeeyu.github.io/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/1d603df7aad64f9f9229d01c24dec8ef.png">
<meta property="og:image" content="https://xiaoeeyu.github.io/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/68e0568c6fec5a195b57dbbf16cff16c.png">
<meta property="og:image" content="https://xiaoeeyu.github.io/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/e2b58c0ed6456f11f738e4b8750a63ee.png">
<meta property="og:image" content="https://xiaoeeyu.github.io/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/1bc297a853f54a8a2bb0571e725d96c9.png">
<meta property="og:image" content="https://xiaoeeyu.github.io/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/e180b2058d4d9b11287f912eff746810.png">
<meta property="og:image" content="https://xiaoeeyu.github.io/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/b2e5460885bf9342412d042119339c1c.png">
<meta property="og:image" content="https://xiaoeeyu.github.io/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/0d588a106bd54741185f3e6945c1fa73.png">
<meta property="og:image" content="https://xiaoeeyu.github.io/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/390dc92a8ce50d36c122e217c6b526f7.png">
<meta property="og:image" content="https://xiaoeeyu.github.io/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/6e3b915f0449d48ab3a7a5e202898502.png">
<meta property="og:image" content="https://xiaoeeyu.github.io/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/ec0258efab5eb24c7d5d9328f7f60598.png">
<meta property="og:image" content="https://xiaoeeyu.github.io/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/image-20221113170928597.png">
<meta property="article:published_time" content="2022-12-11T14:42:00.000Z">
<meta property="article:modified_time" content="2023-10-03T04:59:36.159Z">
<meta property="article:author" content="xiaoeryu">
<meta property="article:tag" content="X86存储器及其保护">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://xiaoeeyu.github.io/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/1b5047235903fba8bbb50f7d347f9a3a.png">
    
    
    <!--- Icon Part-->
    <link rel="icon" type="image/png" href="/images/rabete.jpg" sizes="192x192">
    <link rel="apple-touch-icon" sizes="180x180" href="/images/rabete.jpg">
    <meta name="theme-color" content="#A31F34">
    <link rel="shortcut icon" href="/images/rabete.jpg">
    <!--- Page Info-->
    
    <title>
        
            存储器的保护 | xiaoeryu
        
    </title>

    
<link rel="stylesheet" href="/fonts/Chillax/chillax.css">


    <!--- Inject Part-->
    

    
<link rel="stylesheet" href="/css/style.css">


    
        
<link rel="stylesheet" href="/css/build/tailwind.css">

    

    
<link rel="stylesheet" href="/fonts/GeistMono/geist-mono.css">

    
<link rel="stylesheet" href="/fonts/Geist/geist.css">

    <!--- Font Part-->
    
    
    
    
    
    

    <script id="hexo-configurations">
    window.config = {"hostname":"xiaoeeyu.github.io","root":"/","language":"zh-CN","path":"search.xml"};
    window.theme = {"articles":{"style":{"font_size":"16px","line_height":1.5,"image_border_radius":"14px","image_alignment":"center","image_caption":false,"link_icon":true,"delete_mask":false,"title_alignment":"left","headings_top_spacing":{"h1":"3.2rem","h2":"2.4rem","h3":"1.9rem","h4":"1.6rem","h5":"1.4rem","h6":"1.3rem"}},"word_count":{"enable":true,"count":true,"min2read":true},"author_label":{"enable":true,"auto":false,"list":[]},"code_block":{"copy":true,"style":"mac","highlight_theme":{"light":"github","dark":"vs2015"},"font":{"enable":false,"family":null,"url":null}},"toc":{"enable":true,"max_depth":4,"number":false,"expand":true,"init_open":true},"copyright":{"enable":true,"default":"cc_by_nc_sa"},"lazyload":true,"pangu_js":false,"recommendation":{"enable":false,"title":"推荐阅读","limit":3,"mobile_limit":2,"placeholder":"/images/ball-0101.jpg","skip_dirs":[]}},"colors":{"primary":"#A31F34","secondary":null,"default_mode":"light"},"global":{"fonts":{"chinese":{"enable":false,"family":null,"url":null},"english":{"enable":false,"family":null,"url":null},"title":{"enable":false,"family":null,"url":null}},"content_max_width":"1000px","sidebar_width":"210px","hover":{"shadow":true,"scale":false},"scroll_progress":{"bar":false,"percentage":true},"website_counter":{"url":"https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js","enable":true,"site_pv":true,"site_uv":true,"post_pv":true},"single_page":true,"preloader":{"enable":false,"custom_message":null},"open_graph":true,"google_analytics":{"enable":false,"id":null}},"home_banner":{"enable":true,"style":"fixed","image":{"light":"/images/wallhaven-jxl31y.png","dark":"/images/wallhaven-o5762l.png"},"title":"XIAOERYU","subtitle":{"text":["明心见性，拨云见日","Don't wait, to create"],"hitokoto":{"enable":false,"show_author":false,"api":"https://v1.hitokoto.cn"},"typing_speed":100,"backing_speed":80,"starting_delay":500,"backing_delay":1500,"loop":true,"smart_backspace":true},"text_color":{"light":"#fff","dark":"#d1d1b6"},"text_style":{"title_size":"2.8rem","subtitle_size":"1.5rem","line_height":1.2},"custom_font":{"enable":false,"family":null,"url":null},"social_links":{"enable":true,"style":"default","links":{"github":"https://github.com/xiaoeeyu","instagram":null,"zhihu":null,"twitter":null,"email":"xiaoeryu@163.com"},"qrs":{"weixin":null}}},"plugins":{"feed":{"enable":false},"aplayer":{"enable":false,"type":"fixed","audios":[{"name":null,"artist":null,"url":null,"cover":null,"lrc":null}]},"mermaid":{"enable":false,"version":"9.3.0"}},"version":"2.8.2","navbar":{"auto_hide":false,"color":{"left":"#f78736","right":"#367df7","transparency":35},"width":{"home":"1200px","pages":"1000px"},"links":{"Home":{"path":"/","icon":"fa-regular fa-house"},"Archives":{"path":"/archives","icon":"fa-regular fa-archive"}},"search":{"enable":true,"preload":true}},"page_templates":{"friends_column":2,"tags_style":"blur"},"home":{"sidebar":{"enable":true,"position":"left","first_item":"menu","announcement":null,"show_on_mobile":true,"links":null},"article_date_format":"auto","excerpt_length":200,"categories":{"enable":true,"limit":3},"tags":{"enable":true,"limit":3}},"footerStart":"2022/8/17 11:45:14"};
    window.lang_ago = {"second":"%s 秒前","minute":"%s 分钟前","hour":"%s 小时前","day":"%s 天前","week":"%s 周前","month":"%s 个月前","year":"%s 年前"};
    window.data = {"masonry":false};
  </script>
    
    <!--- Fontawesome Part-->
    
<link rel="stylesheet" href="/fontawesome/fontawesome.min.css">

    
<link rel="stylesheet" href="/fontawesome/brands.min.css">

    
<link rel="stylesheet" href="/fontawesome/solid.min.css">

    
<link rel="stylesheet" href="/fontawesome/regular.min.css">

    
    
    
    
<meta name="generator" content="Hexo 6.3.0">
<style>.github-emoji { position: relative; display: inline-block; width: 1.2em; min-height: 1.2em; overflow: hidden; vertical-align: top; color: transparent; }  .github-emoji > span { position: relative; z-index: 10; }  .github-emoji img, .github-emoji .fancybox { margin: 0 !important; padding: 0 !important; border: none !important; outline: none !important; text-decoration: none !important; user-select: none !important; cursor: auto !important; }  .github-emoji img { height: 1.2em !important; width: 1.2em !important; position: absolute !important; left: 50% !important; top: 50% !important; transform: translate(-50%, -50%) !important; user-select: none !important; cursor: auto !important; } .github-emoji-fallback { color: inherit; } .github-emoji-fallback img { opacity: 0 !important; }</style>
</head>



<body>
	<div class="progress-bar-container">
	

	
	<span class="pjax-progress-bar"></span>
	<!--        <span class="swup-progress-icon">-->
	<!--            <i class="fa-solid fa-circle-notch fa-spin"></i>-->
	<!--        </span>-->
	
</div>

<main class="page-container" id="swup">

	

	<div class="main-content-container flex flex-col justify-between min-h-dvh">
		<div class="main-content-header">
			<header class="navbar-container px-6 md:px-12">
    <div class="navbar-content transition-navbar ">
        <div class="left">
            
                <a class="logo-image h-8 w-8 sm:w-10 sm:h-10 mr-3" href="/">
                    <img src="/images/rabete.jpg" class="w-full h-full rounded-sm">
                </a>
            
            <a class="logo-title" href="/">
                
                xiaoeryu
                
            </a>
        </div>

        <div class="right">
            <!-- PC -->
            <div class="desktop">
                <ul class="navbar-list">
                    
                        
                            

                            <li class="navbar-item">
                                <!-- Menu -->
                                <a class=""
                                   href="/"
                                        >
                                    <i class="fa-regular fa-house fa-fw"></i>
                                    首页
                                    
                                </a>

                                <!-- Submenu -->
                                
                            </li>
                    
                        
                            

                            <li class="navbar-item">
                                <!-- Menu -->
                                <a class=""
                                   href="/archives"
                                        >
                                    <i class="fa-regular fa-archive fa-fw"></i>
                                    归档
                                    
                                </a>

                                <!-- Submenu -->
                                
                            </li>
                    
                    
                        <li class="navbar-item search search-popup-trigger">
                            <i class="fa-solid fa-magnifying-glass"></i>
                        </li>
                    
                </ul>
            </div>
            <!-- Mobile -->
            <div class="mobile">
                
                    <div class="icon-item search search-popup-trigger"><i class="fa-solid fa-magnifying-glass"></i>
                    </div>
                
                <div class="icon-item navbar-bar">
                    <div class="navbar-bar-middle"></div>
                </div>
            </div>
        </div>
    </div>

    <!-- Mobile sheet -->
    <div class="navbar-drawer h-dvh w-full absolute top-0 left-0 bg-background-color flex flex-col justify-between">
        <ul class="drawer-navbar-list flex flex-col px-4 justify-center items-start">
            
                
                    

                    <li class="drawer-navbar-item text-base my-1.5 flex flex-col w-full">
                        
                        <a class="py-1.5 px-2 flex flex-row items-center justify-between gap-1 hover:!text-primary active:!text-primary text-2xl font-semibold group border-b border-border-color hover:border-primary w-full "
                           href="/"
                        >
                            <span>
                                首页
                            </span>
                            
                                <i class="fa-regular fa-house fa-sm fa-fw"></i>
                            
                        </a>
                        

                        
                    </li>
            
                
                    

                    <li class="drawer-navbar-item text-base my-1.5 flex flex-col w-full">
                        
                        <a class="py-1.5 px-2 flex flex-row items-center justify-between gap-1 hover:!text-primary active:!text-primary text-2xl font-semibold group border-b border-border-color hover:border-primary w-full "
                           href="/archives"
                        >
                            <span>
                                归档
                            </span>
                            
                                <i class="fa-regular fa-archive fa-sm fa-fw"></i>
                            
                        </a>
                        

                        
                    </li>
            

            
            
        </ul>

        <div class="statistics flex justify-around my-2.5">
    <a class="item tag-count-item flex flex-col justify-center items-center w-20" href="/tags">
        <div class="number text-2xl sm:text-xl text-second-text-color font-semibold">92</div>
        <div class="label text-third-text-color text-sm">标签</div>
    </a>
    <a class="item tag-count-item flex flex-col justify-center items-center w-20" href="/categories">
        <div class="number text-2xl sm:text-xl text-second-text-color font-semibold">14</div>
        <div class="label text-third-text-color text-sm">分类</div>
    </a>
    <a class="item tag-count-item flex flex-col justify-center items-center w-20" href="/archives">
        <div class="number text-2xl sm:text-xl text-second-text-color font-semibold">112</div>
        <div class="label text-third-text-color text-sm">文章</div>
    </a>
</div>
    </div>

    <div class="window-mask"></div>

</header>


		</div>

		<div class="main-content-body transition-fade-up">
			

			<div class="main-content">
				<div class="post-page-container flex relative justify-between box-border w-full h-full">
	<div class="article-content-container">

		<div class="article-title relative w-full">
			
			<div class="w-full flex items-center pt-6 justify-start">
				<h1 class="article-title-regular text-second-text-color tracking-tight text-4xl md:text-6xl font-semibold px-2 sm:px-6 md:px-8 py-3">存储器的保护</h1>
			</div>
			
		</div>

		
		<div class="article-header flex flex-row gap-2 items-center px-2 sm:px-6 md:px-8">
			<div class="avatar w-[46px] h-[46px] flex-shrink-0 rounded-medium border border-border-color p-[1px]">
				<img src="/images/rabete.jpg">
			</div>
			<div class="info flex flex-col justify-between">
				<div class="author flex items-center">
					<span class="name text-default-text-color text-lg font-semibold">xiaoeryu</span>
					
					<span class="author-label ml-1.5 text-xs px-2 py-0.5 rounded-small text-third-text-color border border-shadow-color-1">Lv5</span>
					
				</div>
				<div class="meta-info">
					<div class="article-meta-info">
    <span class="article-date article-meta-item">
        <i class="fa-regular fa-pen-fancy"></i>&nbsp;
        <span class="desktop">2022-12-11 22:42</span>
        <span class="mobile">2022-12-11 22:42</span>
        <span class="hover-info">创建</span>
    </span>
    
        <span class="article-date article-meta-item">
            <i class="fa-regular fa-wrench"></i>&nbsp;
            <span class="desktop">2023-10-03 12:59:36</span>
            <span class="mobile">2023-10-03 12:59:36</span>
            <span class="hover-info">更新</span>
        </span>
    

    
        <span class="article-categories article-meta-item">
            <i class="fa-regular fa-folders"></i>&nbsp;
            <ul>
                
                
                    
                        
                        <li>
                            <a href="/categories/X86%E6%B1%87%E7%BC%96%EF%BC%9A%E5%AE%9E%E6%A8%A1%E5%BC%8F%E5%88%B0%E4%BF%9D%E6%8A%A4%E6%A8%A1%E5%BC%8F/">X86汇编：实模式到保护模式</a>&nbsp;
                        </li>
                    
                    
                
            </ul>
        </span>
    
    
        <span class="article-tags article-meta-item">
            <i class="fa-regular fa-tags"></i>&nbsp;
            <ul>
                
                    <li>
                        <a href="/tags/X86%E5%AD%98%E5%82%A8%E5%99%A8%E5%8F%8A%E5%85%B6%E4%BF%9D%E6%8A%A4/">X86存储器及其保护</a>&nbsp;
                    </li>
                
            </ul>
        </span>
    

    
    
    
    
        <span class="article-pv article-meta-item">
            <i class="fa-regular fa-eye"></i>&nbsp;<span id="busuanzi_value_page_pv"></span>
        </span>
    
</div>

				</div>
			</div>
		</div>
		

		


		<div class="article-content markdown-body px-2 sm:px-6 md:px-8 pb-8">
			<h2 id="01-MOV-DS-AX和-MOV-DS-EAX"><a href="#01-MOV-DS-AX和-MOV-DS-EAX" class="headerlink" title="01. MOV DS, AX和 MOV DS, EAX"></a>01. MOV DS, AX和 MOV DS, EAX</h2><p>这两条指令计算GDT的逻辑段地址,使用64位除法指令: eax(商)保存段地址, edx(余数)保存偏移<br><code>div r/m32</code></p>
<span id="more"></span>

<img lazyload="" src="/images/loading.svg" data-src="/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/1b5047235903fba8bbb50f7d347f9a3a.png" class="">
<p><code>mov ds, ax</code>在16位操作尺寸下机器码是<mark>8ED8</mark>, 在32位操作尺寸下应该是<mark>668ED8</mark>, 但是Intel的官方文档对这种指令做了优化: </p>
<img lazyload="" src="/images/loading.svg" data-src="/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/b8566b6fdd714d9f20e7ccc8d0d9d4fe.png" class="">
<p>但是有些编译器在编译这条指令的时候仍然会加上<mark>66前缀<mark>所以官方文档建议使用<code>mov ds, eax</code>, 不过在NASM编译器下编译的结果不管是<code>mov ds, eax</code>还是<code>mov ds, ax</code>在16还是32操作尺寸下都不会有<mark>前缀66</mark>.<br>编译之后查看<mark>lst</mark>列表文件:<br>使用16位操作尺寸时:</mark></mark></p>
<img lazyload="" src="/images/loading.svg" data-src="/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/012766565620de75ea1fd36a90d8a8e7.png" class="" title="16位操作尺寸">
<p>使用32位操作尺寸时:</p>
<img lazyload="" src="/images/loading.svg" data-src="/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/a756dd044cdd21358ddb4cd809abbf26.png" class="" title="32位操作尺寸">
<p>可以看到NASM编译器将指令译码成了<mark>8ED8</mark>.<br>处理器不允许在任何时候使用索引字段为<mark>0</mark>的选择子去访问<mark>0号</mark>描述符, 任何时候的访问都会引发异常中断</p>
<img lazyload="" src="/images/loading.svg" data-src="/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/dff722b81cbcf64715b115b92270809e.png" class="" title="0描述符">

<ul>
<li>此节程序设置了<mark>GDT</mark>逻辑地址, 安装了描述符, 加载初始化了<mark>GDTR</mark>, 打开<mark>A20</mark>地址线, 清除中断, 设置CR0寄存器的<strong>PE</strong>位进入保护模式, <strong>jmpf</strong>进入保护模式执行.</li>
</ul>
<h2 id="02-修改段寄存器的保护"><a href="#02-修改段寄存器的保护" class="headerlink" title="02. 修改段寄存器的保护"></a>02. 修改段寄存器的保护</h2><h3 id="本节主要内容-介绍保护模式下修改段寄存器时的保护机制"><a href="#本节主要内容-介绍保护模式下修改段寄存器时的保护机制" class="headerlink" title="本节主要内容:介绍保护模式下修改段寄存器时的保护机制"></a>本节主要内容:介绍保护模式下修改段寄存器时的保护机制</h3><p>保护模式下对段寄存器的修改要分为两步:<br>    1. 将一个描述符选择子带入段选择器此时要检查带入值的合法性<br>    2. 用选择子选择一个描述符并传送到段描述符高速缓存器, 此时要检查描述符的完整性和正确性</p>
<p>在上一节进入到保护模式之后, 执行了<mark>jmpf</mark>, 此时给出的段选择子的<mark>TI位</mark>都是0, 表示要选择的描述符都在<mark>GDT</mark>中. 同时也要执行两步检查来确认这一过程的正确</p>
<ol>
<li><p>将一个描述符选择子带入段选择器此时要检查带入值的合法性</p>
<ol>
<li>处理器会检查访问的描述符的边界, 如果超过了边界条件就会产生一个<mark>异常中断13</mark>, 同时寄存器保持原来的值不变. <img lazyload="" src="/images/loading.svg" data-src="/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/cf7be462210f27a56e9cce8c87d9f08c.png" class=""></li>
</ol>
</li>
<li><p>用选择子选择一个描述符并传送到段描述符高速缓存器, 此时要检查描述符的完整性和正确性</p>
<ol>
<li>确定描述符的类型, 比如描述符<mark>S=1, X=1</mark>, 表示此描述符代表一个代码段, 只能加载到段寄存器CS. 首先表示描述符类型<mark>TYPE</mark>的四个字段必须是有效的(X E W A), 接着按下表检查描述符的类型与段寄存器是否匹配<img lazyload="" src="/images/loading.svg" data-src="/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/7f3245ca542c143d7664e8a2f4f92e11.png" class="">
<img lazyload="" src="/images/loading.svg" data-src="/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/834979e102d8631b7557cc77b899c79c.png" class=""></li>
</ol>
</li>
<li><p>检查描述符中的<mark>P位</mark>是否为1, 若为0表示虽然描述符已经定义, 但是它对应的段并不存在物理内存中, 此时处理器终止处理并引发<mark>11号中断</mark>. 一般来说需要定义一个中断处理程序接管<mark>11号中断</mark>,  在中断处理的过程中把该描述符所对应的段从外部硬盘等存储器中调入内存, 然后将<mark>P位</mark>置1. 这种类型的中断返回时并不是返回到下一条指令二十返回到引起中断的那条指令, 这次就可以重新加载描述符到段寄存器了. 如果<mark>P位=1</mark>处理器将描述符加载到段描述符对应的描述符高速缓存器中, 同时将<mark>A位</mark>置1.<br>代码段在<mark>R=1</mark>的时候类似于只读存储器ROM可以使用段超越前缀CS来读取其中的内容也可以将它们的描述符选择子加载到<mark>DS ES FS GS</mark>来作为数据段访问, 但是代码段在任何时候都是不可写的.</p>
</li>
<li><p>一旦上述验证全部通过, 处理器就将<mark>段选择子</mark>加载到<mark>段寄存器</mark>的<mark>段选择器</mark>中.</p>
</li>
</ol>
<p>另外还有一些注意事项:</p>
<img lazyload="" src="/images/loading.svg" data-src="/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/0eb3ec5d63e3e3e6cd184b56a6239824.png" class="">

<h2 id="03-代码段执行时的保护"><a href="#03-代码段执行时的保护" class="headerlink" title="03. 代码段执行时的保护"></a>03. 代码段执行时的保护</h2><p>进入保护模式之后转移指令<code>jmp 0x0010:flush</code>会修改段寄存器CS, 会进行一系列检查工作:</p>
<ul>
<li>首先选择子<mark>0x0010</mark>指定的描述符不能超过描述符表的边界;</li>
<li>其次指定的描述符必须是代码段描述符, 相关的信息必须是完整且合法的;</li>
<li>还要检查偏移量flush是否超出了当前段的界限. 因为是刚进入保护模式, CS的描述符高速缓存器中的内容还是之前的值, 段界限是<mark>0XFFFF</mark>.<br>一旦通过了检查, 就将<mark>选择子0x0010</mark>带入<mark>CS的段选择器</mark>, 并用描述符填充描述符高速缓存器, 接着用偏移量<mark>flush</mark>修改指令指针寄存器<mark>EIP</mark>, 处理器立即转入目标位置处执行.<br>因为这一条指令刷新了段寄存器<mark>CS</mark>, 导致处理器到一个新的代码段执行.<br>这个描述符指定了<mark>D位是1</mark>表示处理器的默认操作尺寸是32位的, 因为这个描述符所指定的段在<mark>jmp</mark>指令之前是在16位操作尺寸下运行的, 之后是在32位操作尺寸下运行的.<img lazyload="" src="/images/loading.svg" data-src="/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/896a649a211d80d2b5e6992a385fe38c.png" class="">
在保护模式下一旦相应的描述符被加载到CS描述符高速缓存器中, 则处理器取指令和执行指令的时候就不在访问描述符表, 二十直接使用CS描述符高速缓存器的内容, 从中取得线性基地址同指令指针寄存器<mark>EIP</mark>的值相加形成32位线性基地址, 从内存中取得下一条指令.</li>
</ul>
<p>在执行下一条指令之前, 处理器也要检查指令的地址是否有效, 以防止执行超出允许范围之外的指令. </p>
<p>每个段都有其段界限, 位于其描述符中实际使用的段界限其粒度取决于描述符的<mark>G位</mark>, 实际使用的段界限也要满足于<mark>0 &lt; EIP+指令长度-1 &gt;实际使用的段界限</mark>. </p>
<img lazyload="" src="/images/loading.svg" data-src="/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/77aebdb7c57f5f90aec1ef93d6cd2f83.png" class="">

<h2 id="04-用向上扩展的段作为栈段"><a href="#04-用向上扩展的段作为栈段" class="headerlink" title="04. 用向上扩展的段作为栈段"></a>04. 用向上扩展的段作为栈段</h2><p>选择<mark>01号</mark>描述符</p>
<img lazyload="" src="/images/loading.svg" data-src="/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/faa6ecfdc04064593c2187538b016d53.png" class="">
<img lazyload="" src="/images/loading.svg" data-src="/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/20d38262af60146b85491f4fc9e35560.png" class="">
<p>查看<mark>01号段描述符</mark></p>
<img lazyload="" src="/images/loading.svg" data-src="/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/9bb7c4ee6942d6799ec345ab5722dbec.png" class="">

<ul>
<li><strong>基地址</strong>: 为0x00000000</li>
<li><strong>S位</strong>: 为1</li>
<li><strong>X位</strong>: 为0, 表示数据段</li>
<li><strong>E位</strong>: 为0, 表示向上扩展</li>
<li><strong>段界限</strong>: 为0xFFFFF</li>
<li><strong>G位</strong>: 为1, 表示段的粒度为4K字节, 段界限是以4K字节为单位<img lazyload="" src="/images/loading.svg" data-src="/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/72cf5620753aad0a89a78fff765bab5b.png" class=""></li>
</ul>
<p>这个数据段所占用的空间与之前的代码段重叠了, 我们知道代码段是不允许写入的, 但是不允许写入指的是不允许通过代码段的描述符来写入代码段, 是可以通过这个重叠的4G字节的数据段来写入代码段. </p>
<p>设置栈段:</p>
<img lazyload="" src="/images/loading.svg" data-src="/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/5f6bc86c2b0bbfa28ae3ced5216d4e23.png" class="">
<p>二进制<mark>11</mark>是第四个描述符</p>
<img lazyload="" src="/images/loading.svg" data-src="/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/9d4184077cda167885a8ad7a748e3cf7.png" class="">

<ul>
<li><strong>X位</strong>: 为0, 表示为数据段</li>
<li><strong>B位(因为是数据段所以D/B位是B位)</strong>: 为1表示使用<mark>ESP</mark>(为0则使用SP)</li>
<li><strong>E位</strong>: 为0, 表示是向上扩展的段</li>
<li><strong>基地址</strong>: 为0x00006C00</li>
<li><strong>段界限</strong>: 为0x007FF</li>
<li><strong>G位</strong>: 为0, 表示段界限的粒度以字节为单位</li>
</ul>
<img lazyload="" src="/images/loading.svg" data-src="/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/c07413ae69547ac24bc35c6478c45746.png" class="">

<center>这个栈段是数据段, 共2K字节</center>

<p>栈的<mark>扩展方向</mark>和<mark>推进方向</mark>不同, 段扩展方向不是数据的读写方向, 而是用来定义偏移量的范围, 界限检查.<br>段的扩展方向决定了处理器如何对段的访问进行检查</p>
<img lazyload="" src="/images/loading.svg" data-src="/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/992185c00e3d10260709cc14bfc4af81.png" class="">
<p>因为这是数据段, 所以是B位, 且B位的值为1, 表示使用ESP当作栈的指针, 所以要设置ESP的初始值为段的大小(段界限0x7FF + 1 = 0x800 = 2048). </p>
<h2 id="05-向上扩展的段作为栈段时的保护"><a href="#05-向上扩展的段作为栈段时的保护" class="headerlink" title="05. 向上扩展的段作为栈段时的保护"></a>05. 向上扩展的段作为栈段时的保护</h2><p>上一节中使用的栈段为2K字节:</p>
<img lazyload="" src="/images/loading.svg" data-src="/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/38ecf365ff993ff5e8cc0d71e3e3c4b8.png" class="">

<p>且使用<mark>ESP</mark>当作栈指针寄存器来进行隐式的栈操作指令, 如:</p>
<img lazyload="" src="/images/loading.svg" data-src="/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/3dbad33e467a13c4c8bb0f56683128b9.png" class="">
<img lazyload="" src="/images/loading.svg" data-src="/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/650aa3cfe536d7e955920ed47a12a600.png" class="">
<p>这些指令操作时, 会对栈进行压栈, 出栈.</p>
<p>使用下列两条代码演示栈的检查:</p>
<img lazyload="" src="/images/loading.svg" data-src="/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/1b581c0afc4c2bc3e56eb88b6ea86b95.png" class="">

<p>在压入时对偏移量进行检查:</p>
<img lazyload="" src="/images/loading.svg" data-src="/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/0da722cc7dd0fd58228cd9a0786f8b37.png" class="">
<p>第一条指令压栈后的状态, 和检查过程:</p>
<img lazyload="" src="/images/loading.svg" data-src="/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/5233807d22ddc7f010f94b872ed3e281.png" class="">
<img lazyload="" src="/images/loading.svg" data-src="/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/9e8bead96b7411a85c63c58a3f574449.png" class="">
<p>正好符合使用界限的要求, 若将<mark>ESP</mark>的初始值设置为大于0x800比如<mark>0x802</mark>, 再进行压栈指令操作时就会将数据压入到边界之外, 会导致处理器产生中断.</p>
<h2 id="06-访问普通数据段时的保护"><a href="#06-访问普通数据段时的保护" class="headerlink" title="06. 访问普通数据段时的保护"></a>06. 访问普通数据段时的保护</h2><p>将上一节压入的数据弹出:</p>
<img lazyload="" src="/images/loading.svg" data-src="/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/c8cd77849769d1fb3edd1e0250dc51e6.png" class="">

<p>当前栈的布局:</p>
<img lazyload="" src="/images/loading.svg" data-src="/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/e8328caac6a6420bd869459b6bd1b079.png" class="">
<p>首先需要检查出栈的数据是否超出栈的边界:</p>
<img lazyload="" src="/images/loading.svg" data-src="/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/0666f08ce296096fab463e028efe3114.png" class="">

<p>检查通过之后:<br>    1. 使用<mark>SS</mark>的基地址<mark>0x00006C00</mark>加上当前<mark>ESP</mark>中的偏移值<mark>0x07F8</mark>得到有效地址<mark>0x00073F8</mark>, 从这个地址处出去四个字节数据.<br>    2. 之后使用默认的数据段<mark>DS</mark>段地址<mark>0x00000000</mark>加上指令中给出的偏移量<mark>0x0B800</mark>得到有效地址为<mark>0x000B8000</mark>, 将栈中弹出的数据写入此处.<br>    <img lazyload="" src="/images/loading.svg" data-src="/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/1966f897d44a0bafbb6c4950cbe27596.png" class=""><br>    在写入之前, 处理器要检查是否会超出段界限之外:<br>    <img lazyload="" src="/images/loading.svg" data-src="/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/df76be4458212651a62defd71f6b34c4.png" class=""><br>    写入之后数据段<mark>DS</mark>的状态:<br>    <img lazyload="" src="/images/loading.svg" data-src="/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/6a19b8a2865e1c148aede31b98375256.png" class=""><br>    3. 出栈之后, 处理器将<mark>ESP的值加4</mark>变为<mark>0x07FC</mark><br>    <img lazyload="" src="/images/loading.svg" data-src="/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/36ee499be6eca2ea474c7240d2343bef.png" class=""></p>
<h2 id="07-内存线性地址的回绕特性"><a href="#07-内存线性地址的回绕特性" class="headerlink" title="07. 内存线性地址的回绕特性"></a>07. 内存线性地址的回绕特性</h2><p>段的逻辑地址为<mark>0x00000000</mark>, 加上右边的偏移量, 得到逻辑地址</p>
<img lazyload="" src="/images/loading.svg" data-src="/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/fcb649fcc68631430ba4a99f986defb7.png" class="">
<img lazyload="" src="/images/loading.svg" data-src="/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/0e52729cf791d29491cad920d07b0c53.png" class="">
<p>还可以使用下列方式表示偏移量:</p>
<img lazyload="" src="/images/loading.svg" data-src="/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/483ed43e4cf752c5847ddb7949b0e895.png" class="">
<img lazyload="" src="/images/loading.svg" data-src="/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/7b46f7ff6dfa07da667fc96c766bcea2.png" class="">
<img lazyload="" src="/images/loading.svg" data-src="/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/ef863300690948d99350071f8d5464b3.png" class="">

<h2 id="08-用向下扩展的段作为栈段"><a href="#08-用向下扩展的段作为栈段" class="headerlink" title="08. 用向下扩展的段作为栈段"></a>08. 用向下扩展的段作为栈段</h2><p>之前使用向上扩展的段作为栈段, 大小为2K字节.</p>
<img lazyload="" src="/images/loading.svg" data-src="/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/e62ebf4b9bfa8ca5424718326670afec.png" class="">
<p>描述符:</p>
<img lazyload="" src="/images/loading.svg" data-src="/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/2951d97f1dd24b7c5e9cf3b6d522fecf.png" class="">

<ul>
<li>S位: 为1, 表示为寄存器的段描述符</li>
<li>X位: 为0, 表示数据段描述符, 为1表示是代码段描述符</li>
<li>E位: 为0, 表示是向上扩展的段, 为1表示是向下扩展的段<br>向下扩展的数据段实际允许使用的偏移量范围 = 实际允许使用的段界限 + 1开始的, 段内偏移量的最大值为<mark>0xFFFF</mark>或<mark>0xFFFFFFFF</mark>.<img lazyload="" src="/images/loading.svg" data-src="/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/15f11c6a8e4dbf4ebd18d79a9f2aecff.png" class=""></li>
</ul>
<p>对于向下扩展的段:</p>
<img lazyload="" src="/images/loading.svg" data-src="/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/7c598377dd29fff913aca0e7d63b922f.png" class="">

<p>程序中使用的第二个栈段:</p>
<img lazyload="" src="/images/loading.svg" data-src="/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/dc8055320b99f5258a5a34c8309a7f0d.png" class="">

<p>程序中使用的第二个栈段描述符:</p>
<img lazyload="" src="/images/loading.svg" data-src="/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/391097b5520370f4dc8a85612f2a0535.png" class="">
<img lazyload="" src="/images/loading.svg" data-src="/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/ff70bd2dd24a02e094faf74301722bfb.png" class="">

<ul>
<li>S位: 为1, 表示存储器的段描述符</li>
<li>X位: 为0, 表示数据段</li>
<li>段基地址: <mark>0x00007C00</mark></li>
<li>E位: 为1, 表示向下扩展</li>
<li>W位: 为1, 表示可读可写</li>
<li>段界限: <mark>0xFFFFFE</mark></li>
<li>G位: 为1, 表示粒度以<mark>4K字节</mark>为单位</li>
<li>B位: 为1, 表示偏移量理论最大值是<mark>0xFFFFFFFF</mark>, 而且使用<mark>ESP</mark>位栈指针</li>
</ul>
<p>这个栈段的状态如下图:</p>
<img lazyload="" src="/images/loading.svg" data-src="/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/440c379626a7dfa235d192c8f824473c.png" class="">
<p><mark>ESP</mark>的值要设置为栈的最大界限值 + 1: <mark>0xFFFFFFFF +1 = 0x00000000</mark>.</p>
<h2 id="09-向下扩展的段作为栈段时的保护"><a href="#09-向下扩展的段作为栈段时的保护" class="headerlink" title="09. 向下扩展的段作为栈段时的保护"></a>09. 向下扩展的段作为栈段时的保护</h2><p>上一节中设置的栈:</p>
<img lazyload="" src="/images/loading.svg" data-src="/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/609e6f5a2b3b335d37cfc7ebdd66a3ab.png" class="">

<p>使用下列指令执行压栈操作:</p>
<img lazyload="" src="/images/loading.svg" data-src="/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/4c5d56edda424f8df68ea1ca6ab0198f.png" class="">
<p>在执行压栈指令时, 需要对压入的数据进行检查, 以确定不会超出段的界限:</p>
<img lazyload="" src="/images/loading.svg" data-src="/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/1d603df7aad64f9f9229d01c24dec8ef.png" class="">
<p>具体为处理器先执行<mark>ESP - 4 = 0xFFFFFFFC</mark>, 0xFFFFFFFC &gt; 实际使用的段界限<mark>0xFFFFEFFF</mark>, 符合上述条件执行压栈操作. </p>
<p>接下来处理器使用段的基地址<mark>0x00007C00 + 0xFFFFFFFC = 0x00007BFC</mark>, 从这里写入数据.</p>
<img lazyload="" src="/images/loading.svg" data-src="/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/68e0568c6fec5a195b57dbbf16cff16c.png" class="">
<p>压栈后执行出栈操作</p>
<img lazyload="" src="/images/loading.svg" data-src="/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/e2b58c0ed6456f11f738e4b8750a63ee.png" class="">
<p>出栈:</p>
<img lazyload="" src="/images/loading.svg" data-src="/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/1bc297a853f54a8a2bb0571e725d96c9.png" class="">

<h2 id="10-通过别名来实现段的共用和共享"><a href="#10-通过别名来实现段的共用和共享" class="headerlink" title="10. 通过别名来实现段的共用和共享"></a>10. 通过别名来实现段的共用和共享</h2><p>在保护模式下不能使用<mark>CS</mark>来修改内存, 但是可以设置一个代码段的别名描述符, 将其<mark>X位</mark>设置为0表示数据段, 这样就可以通过<mark>ES</mark>来访问字符串所在的内存位置, 以达到修改内存的操作.</p>
<img lazyload="" src="/images/loading.svg" data-src="/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/e180b2058d4d9b11287f912eff746810.png" class="">

<h2 id="11-冒泡排序的基本原理"><a href="#11-冒泡排序的基本原理" class="headerlink" title="11. 冒泡排序的基本原理"></a>11. 冒泡排序的基本原理</h2><img lazyload="" src="/images/loading.svg" data-src="/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/b2e5460885bf9342412d042119339c1c.png" class="">

<h2 id="12-32位操作尺寸下的LOOP指令"><a href="#12-32位操作尺寸下的LOOP指令" class="headerlink" title="12. 32位操作尺寸下的LOOP指令"></a>12. 32位操作尺寸下的LOOP指令</h2><p>如果<mark>CS</mark>高速缓存器中的<mark>D位为0</mark>表示使用16位操作尺寸, <mark>loop</mark>指令使用<mark>cx</mark>计数, 如果<mark>D=1</mark>那么表示使用32位操作尺寸, <mark>loop</mark>使用<mark>ecx</mark>计数.<br>冒泡排序循环:@@1处</p>
<img lazyload="" src="/images/loading.svg" data-src="/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/0d588a106bd54741185f3e6945c1fa73.png" class="">

<p>冒泡排序内循环: @@2处</p>
<img lazyload="" src="/images/loading.svg" data-src="/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/390dc92a8ce50d36c122e217c6b526f7.png" class="">

<p>其中外循环比较次数: 可以看出内循环比较次数和外循环的<mark>ECX</mark>相同</p>
<img lazyload="" src="/images/loading.svg" data-src="/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/6e3b915f0449d48ab3a7a5e202898502.png" class="">

<p>冒泡内循环比较过程:</p>
<img lazyload="" src="/images/loading.svg" data-src="/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/ec0258efab5eb24c7d5d9328f7f60598.png" class="">

<h2 id="13-数据交换指令XCHG"><a href="#13-数据交换指令XCHG" class="headerlink" title="13. 数据交换指令XCHG"></a>13. 数据交换指令XCHG</h2><p><mark>XCHG</mark>指令: 操作数不能同时为内存地址</p>
<img lazyload="" src="/images/loading.svg" data-src="/2022/12/11/24-%E5%AD%98%E5%82%A8%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4/image-20221113170928597.png" class="" title="image-20221113170928597">

		</div>

		
		<div class="post-copyright-info w-full my-8 px-2 sm:px-6 md:px-8">
			<div class="article-copyright-info-container">
    <ul>
        <li><strong>标题:</strong> 存储器的保护</li>
        <li><strong>作者:</strong> xiaoeryu</li>
        <li><strong>创建于
                :</strong> 2022-12-11 22:42:00</li>
        
            <li>
                <strong>更新于
                    :</strong> 2023-10-03 12:59:36
            </li>
        
        <li>
            <strong>链接:</strong> https://github.com/xiaoeryu/2022/12/11/24-存储器的保护/
        </li>
        <li>
            <strong>
                版权声明:
            </strong>
            

            
                本文章采用 <a class="license" target="_blank" rel="noopener" href="https://creativecommons.org/licenses/by-nc-sa/4.0">CC BY-NC-SA 4.0</a> 进行许可。
            
        </li>
    </ul>
</div>

		</div>
		

		
		<ul class="post-tags-box text-lg mt-1.5 flex-wrap justify-center flex md:hidden">
			
			<li class="tag-item mx-0.5">
				<a href="/tags/X86%E5%AD%98%E5%82%A8%E5%99%A8%E5%8F%8A%E5%85%B6%E4%BF%9D%E6%8A%A4/">#X86存储器及其保护</a>&nbsp;
			</li>
			
		</ul>
		

		

		
		<div class="article-nav my-8 flex justify-between items-center px-2 sm:px-6 md:px-8">
			
			<div class="article-prev border-border-color shadow-redefine-flat shadow-shadow-color-2 rounded-medium px-4 py-2 hover:shadow-redefine-flat-hover hover:shadow-shadow-color-2">
				<a class="prev" rel="prev" href="/2022/12/11/25-%E4%BF%9D%E6%8A%A4%E6%A8%A1%E5%BC%8F%E7%A8%8B%E5%BA%8F%E7%9A%84%E5%8A%A8%E6%80%81%E5%8A%A0%E8%BD%BD%E5%92%8C%E6%89%A7%E8%A1%8C/">
					<span class="left arrow-icon flex justify-center items-center">
						<i class="fa-solid fa-chevron-left"></i>
					</span>
					<span class="title flex justify-center items-center">
						<span class="post-nav-title-item">保护模式程序的动态加载和执行</span>
						<span class="post-nav-item">上一篇</span>
					</span>
				</a>
			</div>
			
			
			<div class="article-next border-border-color shadow-redefine-flat shadow-shadow-color-2 rounded-medium px-4 py-2 hover:shadow-redefine-flat-hover hover:shadow-shadow-color-2">
				<a class="next" rel="next" href="/2022/12/11/23-%E6%8C%87%E4%BB%A4%E7%9A%84%E6%A0%BC%E5%BC%8F%E5%8F%8A%E5%85%B6%E6%93%8D%E4%BD%9C%E5%B0%BA%E5%AF%B8/">
					<span class="title flex justify-center items-center">
						<span class="post-nav-title-item">指令的格式及其操作尺寸</span>
						<span class="post-nav-item">下一篇</span>
					</span>
					<span class="right arrow-icon flex justify-center items-center">
						<i class="fa-solid fa-chevron-right"></i>
					</span>
				</a>
			</div>
			
		</div>
		


		
		<div class="comment-container px-2 sm:px-6 md:px-8 pb-8">
			<div class="comments-container mt-10 w-full ">
    <div id="comment-anchor" class="w-full h-2.5"></div>
    <div class="comment-area-title w-full my-1.5 md:my-2.5 text-xl md:text-3xl font-bold">
        评论
    </div>
    

        
            


        
    
</div>

		</div>
		
	</div>

	
	<div class="toc-content-container">
		<div class="post-toc-wrap">
	<div class="post-toc">
		<div class="toc-title">目录</div>
		<div class="page-title">存储器的保护</div>
		<ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#01-MOV-DS-AX%E5%92%8C-MOV-DS-EAX"><span class="nav-text">01. MOV DS, AX和 MOV DS, EAX</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#02-%E4%BF%AE%E6%94%B9%E6%AE%B5%E5%AF%84%E5%AD%98%E5%99%A8%E7%9A%84%E4%BF%9D%E6%8A%A4"><span class="nav-text">02. 修改段寄存器的保护</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#%E6%9C%AC%E8%8A%82%E4%B8%BB%E8%A6%81%E5%86%85%E5%AE%B9-%E4%BB%8B%E7%BB%8D%E4%BF%9D%E6%8A%A4%E6%A8%A1%E5%BC%8F%E4%B8%8B%E4%BF%AE%E6%94%B9%E6%AE%B5%E5%AF%84%E5%AD%98%E5%99%A8%E6%97%B6%E7%9A%84%E4%BF%9D%E6%8A%A4%E6%9C%BA%E5%88%B6"><span class="nav-text">本节主要内容:介绍保护模式下修改段寄存器时的保护机制</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#03-%E4%BB%A3%E7%A0%81%E6%AE%B5%E6%89%A7%E8%A1%8C%E6%97%B6%E7%9A%84%E4%BF%9D%E6%8A%A4"><span class="nav-text">03. 代码段执行时的保护</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#04-%E7%94%A8%E5%90%91%E4%B8%8A%E6%89%A9%E5%B1%95%E7%9A%84%E6%AE%B5%E4%BD%9C%E4%B8%BA%E6%A0%88%E6%AE%B5"><span class="nav-text">04. 用向上扩展的段作为栈段</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#05-%E5%90%91%E4%B8%8A%E6%89%A9%E5%B1%95%E7%9A%84%E6%AE%B5%E4%BD%9C%E4%B8%BA%E6%A0%88%E6%AE%B5%E6%97%B6%E7%9A%84%E4%BF%9D%E6%8A%A4"><span class="nav-text">05. 向上扩展的段作为栈段时的保护</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#06-%E8%AE%BF%E9%97%AE%E6%99%AE%E9%80%9A%E6%95%B0%E6%8D%AE%E6%AE%B5%E6%97%B6%E7%9A%84%E4%BF%9D%E6%8A%A4"><span class="nav-text">06. 访问普通数据段时的保护</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#07-%E5%86%85%E5%AD%98%E7%BA%BF%E6%80%A7%E5%9C%B0%E5%9D%80%E7%9A%84%E5%9B%9E%E7%BB%95%E7%89%B9%E6%80%A7"><span class="nav-text">07. 内存线性地址的回绕特性</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#08-%E7%94%A8%E5%90%91%E4%B8%8B%E6%89%A9%E5%B1%95%E7%9A%84%E6%AE%B5%E4%BD%9C%E4%B8%BA%E6%A0%88%E6%AE%B5"><span class="nav-text">08. 用向下扩展的段作为栈段</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#09-%E5%90%91%E4%B8%8B%E6%89%A9%E5%B1%95%E7%9A%84%E6%AE%B5%E4%BD%9C%E4%B8%BA%E6%A0%88%E6%AE%B5%E6%97%B6%E7%9A%84%E4%BF%9D%E6%8A%A4"><span class="nav-text">09. 向下扩展的段作为栈段时的保护</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#10-%E9%80%9A%E8%BF%87%E5%88%AB%E5%90%8D%E6%9D%A5%E5%AE%9E%E7%8E%B0%E6%AE%B5%E7%9A%84%E5%85%B1%E7%94%A8%E5%92%8C%E5%85%B1%E4%BA%AB"><span class="nav-text">10. 通过别名来实现段的共用和共享</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#11-%E5%86%92%E6%B3%A1%E6%8E%92%E5%BA%8F%E7%9A%84%E5%9F%BA%E6%9C%AC%E5%8E%9F%E7%90%86"><span class="nav-text">11. 冒泡排序的基本原理</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#12-32%E4%BD%8D%E6%93%8D%E4%BD%9C%E5%B0%BA%E5%AF%B8%E4%B8%8B%E7%9A%84LOOP%E6%8C%87%E4%BB%A4"><span class="nav-text">12. 32位操作尺寸下的LOOP指令</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#13-%E6%95%B0%E6%8D%AE%E4%BA%A4%E6%8D%A2%E6%8C%87%E4%BB%A4XCHG"><span class="nav-text">13. 数据交换指令XCHG</span></a></li></ol>

	</div>
</div>
	</div>
	
</div>
			</div>

			
		</div>

		<div class="main-content-footer">
			<footer class="footer mt-5 py-5 h-auto text-base text-third-text-color relative border-t-2 border-t-border-color">
    <div class="info-container py-3 text-center">
        
        <div class="text-center">
            &copy;
            
              <span>2022</span>
              -
            
            2025&nbsp;&nbsp;<i class="fa-solid fa-heart fa-beat" style="--fa-animation-duration: 0.5s; color: #f54545"></i>&nbsp;&nbsp;<a href="/">xiaoeryu</a>
            
                
                <p class="post-count space-x-0.5">
                    <span>
                        共撰写了 112 篇文章
                    </span>
                    
                </p>
            
        </div>
        
            <script data-swup-reload-script src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
            <div class="relative text-center lg:absolute lg:right-[20px] lg:top-1/2 lg:-translate-y-1/2 lg:text-right">
                
                    <span id="busuanzi_container_site_uv" class="lg:!block">
                        <span class="text-sm">访问人数</span>
                        <span id="busuanzi_value_site_uv"></span>
                    </span>
                
                
                    <span id="busuanzi_container_site_pv" class="lg:!block">
                        <span class="text-sm">总访问量</span>
                        <span id="busuanzi_value_site_pv"></span>
                    </span>
                
            </div>
        
        <div class="relative text-center lg:absolute lg:left-[20px] lg:top-1/2 lg:-translate-y-1/2 lg:text-left">
            <span class="lg:block text-sm">由 <?xml version="1.0" encoding="utf-8"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg class="relative top-[2px] inline-block align-baseline" version="1.1" id="圖層_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="1rem" height="1rem" viewBox="0 0 512 512" enable-background="new 0 0 512 512" xml:space="preserve"><path fill="#0E83CD" d="M256.4,25.8l-200,115.5L56,371.5l199.6,114.7l200-115.5l0.4-230.2L256.4,25.8z M349,354.6l-18.4,10.7l-18.6-11V275H200v79.6l-18.4,10.7l-18.6-11v-197l18.5-10.6l18.5,10.8V237h112v-79.6l18.5-10.6l18.5,10.8V354.6z"/></svg><a target="_blank" class="text-base" href="https://hexo.io">Hexo</a> 驱动</span>
            <span class="text-sm lg:block">主题&nbsp;<a class="text-base" target="_blank" href="https://github.com/EvanNotFound/hexo-theme-redefine">Redefine v2.8.2</a></span>
        </div>
        
        
            <div>
                博客已运行 <span class="odometer" id="runtime_days" ></span> 天 <span class="odometer" id="runtime_hours"></span> 小时 <span class="odometer" id="runtime_minutes"></span> 分钟 <span class="odometer" id="runtime_seconds"></span> 秒
            </div>
        
        
            <script data-swup-reload-script>
                try {
                    function odometer_init() {
                    const elements = document.querySelectorAll('.odometer');
                    elements.forEach(el => {
                        new Odometer({
                            el,
                            format: '( ddd).dd',
                            duration: 200
                        });
                    });
                    }
                    odometer_init();
                } catch (error) {}
            </script>
        
        
        
    </div>  
</footer>
		</div>
	</div>

	
	<div class="post-tools">
		<div class="post-tools-container">
	<ul class="article-tools-list">
		<!-- TOC aside toggle -->
		
		<li class="right-bottom-tools page-aside-toggle">
			<i class="fa-regular fa-outdent"></i>
		</li>
		

		<!-- go comment -->
		
		<li class="go-comment">
			<i class="fa-regular fa-comments"></i>
		</li>
		
	</ul>
</div>
	</div>
	

	<div class="right-side-tools-container">
		<div class="side-tools-container">
	<ul class="hidden-tools-list">
		<li class="right-bottom-tools tool-font-adjust-plus flex justify-center items-center">
			<i class="fa-regular fa-magnifying-glass-plus"></i>
		</li>

		<li class="right-bottom-tools tool-font-adjust-minus flex justify-center items-center">
			<i class="fa-regular fa-magnifying-glass-minus"></i>
		</li>

		<li class="right-bottom-tools tool-dark-light-toggle flex justify-center items-center">
			<i class="fa-regular fa-moon"></i>
		</li>

		<!-- rss -->
		

		

		<li class="right-bottom-tools tool-scroll-to-bottom flex justify-center items-center">
			<i class="fa-regular fa-arrow-down"></i>
		</li>
	</ul>

	<ul class="visible-tools-list">
		<li class="right-bottom-tools toggle-tools-list flex justify-center items-center">
			<i class="fa-regular fa-cog fa-spin"></i>
		</li>
		
		<li class="right-bottom-tools tool-scroll-to-top flex justify-center items-center">
			<i class="arrow-up fas fa-arrow-up"></i>
			<span class="percent"></span>
		</li>
		
		
	</ul>
</div>
	</div>

	<div class="image-viewer-container">
	<img src="">
</div>

	
	<div class="search-pop-overlay">
	<div class="popup search-popup">
		<div class="search-header">
			<span class="search-input-field-pre">
				<i class="fa-solid fa-keyboard"></i>
			</span>
			<div class="search-input-container">
				<input autocomplete="off" autocorrect="off" autocapitalize="off" placeholder="站内搜索您需要的内容..." spellcheck="false" type="search" class="search-input">
			</div>
			<span class="popup-btn-close">
				<i class="fa-solid fa-times"></i>
			</span>
		</div>
		<div id="search-result">
			<div id="no-result">
				<i class="fa-solid fa-spinner fa-spin-pulse fa-5x fa-fw"></i>
			</div>
		</div>
	</div>
</div>
	

</main>



<script src="/js/build/libs/Swup.min.js"></script>

<script src="/js/build/libs/SwupSlideTheme.min.js"></script>

<script src="/js/build/libs/SwupScriptsPlugin.min.js"></script>

<script src="/js/build/libs/SwupProgressPlugin.min.js"></script>

<script src="/js/build/libs/SwupScrollPlugin.min.js"></script>

<script src="/js/build/libs/SwupPreloadPlugin.min.js"></script>

<script>
    const swup = new Swup({
        plugins: [
            new SwupScriptsPlugin({
                optin: true,
            }),
            new SwupProgressPlugin(),
            new SwupScrollPlugin({
                offset: 80,
            }),
            new SwupSlideTheme({
                mainElement: ".main-content-body",
            }),
            new SwupPreloadPlugin(),
        ],
        containers: ["#swup"],
    });
</script>




	
<script src="/js/build/tools/imageViewer.js" type="module"></script>

<script src="/js/build/utils.js" type="module"></script>

<script src="/js/build/main.js" type="module"></script>

<script src="/js/build/layouts/navbarShrink.js" type="module"></script>

<script src="/js/build/tools/scrollTopBottom.js" type="module"></script>

<script src="/js/build/tools/lightDarkSwitch.js" type="module"></script>

<script src="/js/build/layouts/categoryList.js" type="module"></script>



    
<script src="/js/build/tools/localSearch.js" type="module"></script>




    
<script src="/js/build/tools/codeBlock.js" type="module"></script>




    
<script src="/js/build/layouts/lazyload.js" type="module"></script>




    
<script src="/js/build/tools/runtime.js"></script>

    
<script src="/js/build/libs/odometer.min.js"></script>

    
<link rel="stylesheet" href="/assets/odometer-theme-minimal.css">




  
<script src="/js/build/libs/Typed.min.js"></script>

  
<script src="/js/build/plugins/typed.js" type="module"></script>








    
<script src="/js/build/libs/anime.min.js"></script>





    
<script src="/js/build/tools/tocToggle.js" type="module" data-swup-reload-script=""></script>

<script src="/js/build/layouts/toc.js" type="module" data-swup-reload-script=""></script>

<script src="/js/build/plugins/tabs.js" type="module" data-swup-reload-script=""></script>




<script src="/js/build/libs/moment-with-locales.min.js" data-swup-reload-script=""></script>


<script src="/js/build/layouts/essays.js" type="module" data-swup-reload-script=""></script>





	
</body>

</html>